import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { InOrderVO, InOrderForm, InOrderQuery } from '@/api/wmscloud/inOrder/types';

/**
 * 查询入库单列表
 * @param query
 * @returns {*}
 */

export const listInOrder = (query?: InOrderQuery): AxiosPromise<InOrderVO[]> => {
  return request({
    url: '/wmsCloud/inOrder/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询入库单详细
 * @param orderId
 */
export const getInOrder = (orderId: string | number): AxiosPromise<InOrderVO> => {
  return request({
    url: '/wmsCloud/inOrder/' + orderId,
    method: 'get'
  });
};

/**
 * 新增入库单
 * @param data
 */
export const addInOrder = (data: InOrderForm) => {
  return request({
    url: '/wmsCloud/inOrder',
    method: 'post',
    data: data
  });
};

/**
 * 修改入库单
 * @param data
 */
export const updateInOrder = (data: InOrderForm) => {
  return request({
    url: '/wmsCloud/inOrder',
    method: 'put',
    data: data
  });
};

/**
 * 删除入库单
 * @param orderId
 */
export const delInOrder = (orderId: string | number | Array<string | number>) => {
  return request({
    url: '/wmsCloud/inOrder/' + orderId,
    method: 'delete'
  });
};

/**
 * 打印入库单详细
 * @param orderId
 */
export const printInOrder = (orderId: string | number )=> {
  return request({
    url: '/wmsCloud/inOrder/printInOrderDetail/' + orderId,
    method: 'get',
    responseType: 'arraybuffer',
    headers: {
      'Content-Type': 'application/json'
    },
  })
}
